<?php
/**
 * Description
 * 
 * PHP version 7
 * 
 * @category Custom
 * @package  Custom
 * @author   ryu <mo5467@126.com>
 * @date     2020-04-23 01:31:41
 * @lastTime 2020-05-01 23:15:13
 * @license  https://opensource.org/licenses/MIT MIT License
 * @link     none
 */

namespace Test\Unit;

use InvalidArgumentException;
use Design\Creational\StaticFactory\StaticFactory;
use Design\Creational\StaticFactory\NumberFormatter;
use Design\Creational\StaticFactory\StringFormatter;

class StaticFactoryTest extends \Test\BaseTest
{


    public function testCanCreateFormatter()
    {
        $formatter = StaticFactory::factory('string');
        $this->assertInstanceOf(StringFormatter::class, $formatter);
        $this->assertSame('test', $formatter->format('test'));

        $formatter = StaticFactory::factory('number');
        $this->assertInstanceOf(NumberFormatter::class, $formatter);
        $this->assertSame('123', $formatter->format('123.34'));

        $this->expectException(InvalidArgumentException::class);
        $formatter = StaticFactory::factory('test');

    }//end testCanCreateFormatter()


}//end class
